<template>
  <div id="carouselExampleControls" class="carousel slide" data-ride="carousel" :data-interval="false">
    <div class="carousel-inner">
      <div class="carousel-item active">
        <div class="item-container">
          <div class="img-item col-12">
            <a href="">
              <img :src="CourseData[0]?.image" class="d-inline-block" alt="..." />
            </a>
            <div class="course-info">
              <div class="course-title">
                <p>{{ CourseData[0]?.title }}</p>
              </div>
              <p class="course-students">
                加入学员：{{ CourseData[0]?.students }}人
              </p>
            </div>
          </div>
          <div class="img-item col-12">
            <img :src="CourseData[1]?.image" class="d-inline-block" alt="..." />
            <div class="course-info">
              <div class="course-title">
                <p>{{ CourseData[1]?.title }}</p>
              </div>
              <p class="course-students">
                加入学员：{{ CourseData[1]?.students }}人
              </p>
            </div>
          </div>
        </div>
      </div>
      <div class="carousel-item">
        <div class="item-container">
          <div class="img-item col-12">
            <img :src="CourseData[2]?.image" class="d-inline-block" alt="..." />
            <div class="course-info">
              <div class="course-title">
                <p>{{ CourseData[2]?.title }}</p>
              </div>
              <p class="course-students">
                加入学员：{{ CourseData[2]?.students }}人
              </p>
            </div>
          </div>
          <div class="img-item col-12">
            <img :src="CourseData[3]?.image" class="d-inline-block" alt="..." />
            <div class="course-info">
              <div class="course-title">
                <p>{{ CourseData[3]?.title }}</p>
              </div>
              <p class="course-students">
                加入学员：{{ CourseData[3]?.students }}人
              </p>
            </div>
          </div>
        </div>
      </div>
      <div class="carousel-item">
        <div class="item-container">
          <div class="img-item col-12">
            <img :src="CourseData[4]?.image" class="d-inline-block" alt="..." />
            <div class="course-info">
              <div class="course-title">
                <p>{{ CourseData[4]?.title }}</p>
              </div>
              <p class="course-students">
                加入学员：{{ CourseData[4]?.students }}人
              </p>
            </div>
          </div>
          <div class="img-item col-12">
            <img :src="CourseData[5]?.image" class="d-inline-block" alt="..." />
            <div class="course-info">
              <div class="course-title">
                <p>{{ CourseData[5]?.title }}</p>
              </div>
              <p class="course-students">
                加入学员：{{ CourseData[5]?.students }}人
              </p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
</template>

<script>
import { reactive } from 'vue'
export default {
  props: ['CourseData'],
  setup () {
  }
}
</script>

<style lang="scss" scoped>
.carousel-item {
  height: 315px;
  @media (max-width: 1200px) {
    height: 285px;
  }
  @media (max-width: 992px) {
    height: 258px;
  }
  @media (max-width: 768px) {
    height: 196px;
  }
  @media (max-width: 576px) {
    height: auto !important;
  }
  .item-container {
    height: 100%;
    .img-item {
      height: 100%;
      display: inline-block;
      padding: 0;
      @media (max-width: 576px) {
        display: block;
        width: 100%;
        margin-bottom: 10px;
        padding: 0;
      }
      position: relative;
      width: 50%;
      @media (min-width: 576px) {
        &:first-child {
          padding-right: 20px;
        }
      }
      .course-info {
        width: 100%;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        .course-title {
          margin: 0 auto;
          padding: 5px 30px;
          width: 60%;
          border: 3px solid #fff;
          p {
            color: #fff;
            font-size: 20px;
            font-weight: 600;
            text-align: center;
            margin-top: 20px;
          }
        }
        .course-students {
          color: #fff;
          font-size: 16px;
          font-weight: 400;
          text-align: center;
          margin-top: 20px;
        }
      }
      img {
        width: 100%;
        height: 100%;
        @media (max-width: 576px) {
          height: 238px;
        }
        background-color: #f5f5f5;
      }
    }
  }
}
.carousel-control-prev {
  background-color: gray;
  top: 50% !important;
  height: 150px !important;
  transform: translateY(-50%);
  width: 5%;
}
.carousel-control-next {
  background-color: gray;
  top: 50% !important;
  height: 150px !important;
  transform: translateY(-50%);
  width: 5%;
}
</style>
